//
// Created by lmliang on 3/28/17.
//
#include <stdlib.h>
#include <stdio.h>
#include "backtrace.h"

int fun1(int i)
{
    if (i < 2)
    {
        fun1(++i);
    }
    else
    {
        int *p = NULL;
        *p = 2;
    }
    return 0;
}

void fun2()
{
    int i = 0;
    ++i;
    fun1(0);
    i = 9;
}

void fun3()
{
    int i = 0;
    ++i;
    fun2();
    i = 5;
}

void func_c()
{
    *((volatile char *)0x0) = 0x9999;
}

void func_b()
{
    func_c();
}

void func_a()
{
    func_b();
}

void output(const char* msg)
{
    printf("%s\n", msg);
}

int main()
{
    if (init_sig_action(output) == -1)
        return -1;
    func_a();
    fun3();

    return 0;
}

